package net.findkrypton.event;

import java.util.ArrayList;
import java.util.List;

import javafx.scene.image.Image;
import javafx.scene.input.MouseButton;
import javafx.scene.text.Font;
import net.findkrypton.entity.LoopUpdateBase;
import net.findkrypton.entity.TextStateBase;
import net.jumpengine.Manager;
import net.jumpengine.bean.Base;
import net.jumpengine.bean.ButtonBase;
import net.jumpengine.bean.TextBase;
import net.jumpengine.enume.GameState;
import net.jumpengine.inter.IAction;
import net.jumpengine.inter.IStateEvent;
import net.jumpengine.manager.ImageManager;
import net.jumpengine.po.Border;
import net.jumpengine.util.UIO;

public class HelpStateEvent implements IStateEvent {
	private boolean load=false;
	
	private TextBase numBase;
	private List<TextStateBase> numberBox=new ArrayList<TextStateBase>();
	private LoopUpdateBase loopUpdateBase;

	@Override
	public boolean isLoaded() {
		return load;
	}

	@Override
	public void load() {
		ImageManager im = Manager.getImageManager();
		
		Font font=new Font("黑体",25);
		ButtonBase btu=new ButtonBase(20, 10, 221, 51, "< 返回游戏界面     ");
		btu.setFont(font);
		btu.setAction(new IAction() {
			@Override
			public void handle(int x, int y, MouseButton button, Base base) {
				Manager.setState(GameState.start);				
			}
		});
		im.add(btu);
		
		List<Image> list = UIO.loadImages("/help",this.getClass());
		loopUpdateBase = new LoopUpdateBase(230,190,1000,list,this);
		im.add(loopUpdateBase);
		
		TextStateBase box;
		Border border=new Border(2,2,2,2,0);
		NumberBoxAction action=new NumberBoxAction(this);
		for(int i=0;i<list.size();i++) {
			box=new TextStateBase(190+i*80, 90, 51, 51, i+1+"", border);
			box.setFont(font);
			box.setAction(action);
			im.add(box);
			numberBox.add(box);
		}
		
		numBase=new TextBase(510, 100, "0");
		numBase.setFont(font);
		im.add(numBase);
		
		TextBase text=new TextBase(590, 100, "点击数字块停止自动循环播放.");
		text.setFont(font);
		im.add(text);
		
		font=new Font("黑体", 35);
		text=new TextBase(252, 410, "游戏引擎：JumpEngine(跳跃引擎)");
		text.setFont(font);
		im.add(text);
		
		font=new Font("黑体", 35);
		text=new TextBase(360, 490, "设计：风中的雪糕\n美术：风中的雪糕\n程序：风中的雪糕\n哔哩哔哩：风中的雪糕\n知乎：风中的雪糕\n贴吧：ztw1122");
		text.setFont(font);
		im.add(text);
		
		load=true;
	}
	
	@Override
	public void show() {
				
	}

	@Override
	public void pause() { }

	@Override
	public void end() { }

	public TextBase getNumBase() {
		return numBase;
	}

	public List<TextStateBase> getNumberBox() {
		return numberBox;
	}

	public LoopUpdateBase getLoopUpdateBase() {
		return loopUpdateBase;
	}

	@Override
	public void setBackImage(Image image) {
		// TODO Auto-generated method stub
		
	}
}
